package com.rockcent.job.task.demo;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.Banner;
import com.rockcent.mall.lib.repository.BannerRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * fixedRate例子：固定频率来执行线程任务
 * Created by zhangjh on 2016/11/23.
 */
//@Component
public class ScheduledFixedRateTasks {


    private static final Logger log = LoggerFactory.getLogger(ScheduledFixedRateTasks.class);

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Autowired
    private BannerRepository bannerRepository;

//    @Scheduled(fixedRate = 3000)
    public void reportCurrentTime() {
        log.info("======================>The time is now {}", dateFormat.format(new Date()));
//        Banner banner = bannerRepository.findTop1ByIsDeleteOrderBySeqNoDesc(Whether.NO);
//        log.info(banner.toString());
    }
}
